#!/bin/bash

# This script initiates regeneration of Makefile.am and builds OCRopus.
# It should only be called by OCRopus developers.

# If autotools exist, Makefile.am is generated and autotools are invoked.
# All arguments to this script are forwarded as-is to configure.

if [ `which python` ]
then
    if [ `which autoreconf` ]
    then
        echo "# generating Makefile.am"
        python genAM.py > Makefile.am
        echo "# running autoreconf"
        autoreconf
        if [ $? != 0 ]
        then
            exit
        fi
    fi
fi

echo "# running configure $@"
./configure "$@"
if [ $? != 0 ]
then
    exit
fi

echo "# please run make now"
# make
